<template>
  <div class="recommend" v-if="recommendData.length > 0">
    <!-- <h2 class="hometitle">推荐文章</h2> -->
    <div class="recommendTitle">推荐文章<small-ico></small-ico></div>

    <ul class="sidenews">
      <li v-for="(item, index) in recommendData" :key="index" class="sidenew">
        <router-link :to="`/article/${item.id}`">
          <p><a href="javascript:void(0);">{{index+1}}、{{item.title}}</a></p>
          <i class="iconfont icon-shijian"></i>
          <a class="createTime" href="javascript:void(0);">{{item.createTime | parseTime}}</a>
        </router-link>
      </li>
    </ul>
  </div>
</template>

<script>
import { getBlogByLevel } from '@/api'
import sectionTitle from '@/components/section-title'
import SmallIco from '@/components/small-ico'
export default {
  name: 'Recommend',
  data() {
    return {
      recommendData: [],
      topReq: {
        "index": 0,
        "size": 3,
        "ascOrDesc": "DESC",
        "queryDto":{
          "online": 1,
          "isTop": 1
        },
        "properties": ["is_top","update_time","is_essence","comment_count","read_count"]
      }
    }
  },
  components: {
    sectionTitle,
    SmallIco
  },
  created() {
    this.getRecommendBlog()
  },
  methods: {
    getRecommendBlog() {
      var params = this.topReq;
      getBlogByLevel(params).then(res => {
          this.recommendData = res.data.data.result || []
      })
    },

    //跳转到文章详情
    // goToInfo(uid) {

    //   let routeData = this.$router.resolve({ path: "/info", query: { blogUid: uid } });
    //   window.open(routeData.href, '_blank');
    // }
  },

}
</script>

<style scoped lang="less">
.recommend {
  padding: 15px;

  .recommendTitle {
    font-size: 18px;
    color: currentColor;
    font-weight: 600;
    display: flex;
    align-items: flex-end;
    text-overflow: ellipsis;
  }
  .sidenews {
    .sidenew {
      line-height:18px;
      margin-top: 15px;
      font-size: 14px;
      overflow: hidden;
      p {
        margin-bottom: 5px;
      }
      .iconfont {
        margin-right: 5px;
        // margin: 0 5px;
      }
      .createTime,
      .iconfont {
        font-size: 12px;
        color: #9a9a9a;
      }
    }
  }
}
/* .hometitle {
  font-size: 18px;
  color: #282828;
  font-weight: 600;
  margin: 0;
  text-transform: uppercase;
  padding-bottom: 15px;
  margin-bottom: 25px;
  position: relative;
}
.hometitle:after {
  content: "";
  background-color: #282828;
  left: 0;
  width: 50px;
  height: 2px;
  bottom: 0;
  position: absolute;
  -webkit-transition: 0.5s;
  -moz-transition: 0.5s;
  -ms-transition: 0.5s;
  -o-transition: 0.5s;
  transition: 0.5s;
}
.recommend:hover ::after {
  width: 70px;
}

.sidenews li {
  padding-left: 20px;
  margin: 0 0 10px 0;
  overflow: hidden;
}
.sidenews li p {
  line-height: 24px;
  color: #888;
  font-size: 15px;
  overflow: hidden;
  text-overflow: ellipsis;
  -webkit-box-orient: vertical;
  display: -webkit-box;
  -webkit-line-clamp: 2;
}
.sidenews li a {
  color: #48494d;
}
.sidenews li a:hover {
  color: #00a7eb;
}
.sidenews i {
  width: 100px;
  height: 75px;
  overflow: hidden;
  display: block;
  border: #efefef 1px solid;
  float: left;
  margin-right: 10px;
}
.sidenews img {
  height: 100%;
  max-height: 75px;
  margin: auto;
  -moz-transition: all 0.5s ease;
  -webkit-transition: all 0.5s ease;
  -ms-transition: all 0.5s ease;
  -o-transition: all 0.5s ease;
  transition: all 0.5s ease;
  transition: all 0.5s;
}
.sidenews li:hover i img {
  transform: scale(1.1);
}
.sidenews span {
  font-size: 12px;
  color: #9a9a9a;
  margin-top: 10px;
  display: block;
} */
</style>
